<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
        <div class="center_box">
        	<div class="center_box_nav center_context_nav">
            	<div class="center_banner">
                	<a href="javascript:location.href='${ctx}/front!viewIndex.action';" title="首页">首页</a>&gt;&nbsp;文章&gt;&nbsp;<a href="javascript:location.href='${ctx}/front!viewContextList.action?classId=${classId}';"><c:if test="${'A000'==classId}">营养</c:if><c:if test="${'B000'==classId}">扮靓</c:if><c:if test="${'C000'==classId}">用品</c:if><c:if test="${'D000'==classId}">娱乐</c:if>资讯</a>
                </div>
             </div>
            <div class=" clearfix">
            	<div class="context_list_show bg_white">
                	<ul class="clearfix" id='msgContent'>
               	 	</ul>
                    <div class="list_page">
						<div class="list_page_inner">
							<span>第</span>
							<span class="page_go">
								<input type="text" id="page" value="1"/><a href="javascript:clickGo('page');" class="page_go_bt"></a>
							</span>
							<span id="allPage_show">页 共1页</span>                        
							<a href="javascript:movePre();"  id='preBt' class="page_pre_unable"></a>
							<a href="javascript:moveNext();" id='nextBt' class="page_next"></a>
						</div>                    
					</div> 
                </div>
              	<div class="context_rank_box">
                    <div class="context_inner clearfix">
                    	<h2>猜你喜欢</h2>
                        <div class="context_titles">
                        	<ul class="context_guess" id='guessContent'>	
                            </ul>
                            <div class="list_page">
                                <div class="list_page_inner">
                                    <a href="javascript:doGuessQuery();" class="page_pre"></a>
                                    <a href="javascript:doGuessQuery();" class="page_next"></a>
                                </div>  
                    		</div>
                        </div>
                    </div>
                </div>                
            </div>	
        </div>
<script type="text/javascript">
<!--
var pageSize=9;//文章列表页面大小
var allPage;//总页数
var allCount;//总记录数
var curPage=1;//当前页数

//查询文章列表
function doMsgQuery(){	
	var url="${ctx}/front!getContextList.action";
	$.post(url, "q_classId=${classId}&page="+curPage+"&pageSize="+pageSize ,function callback(txt){   
		var json = $.parseJSON(txt);
			if (json.code==0) {	
				allCount=json.count;
				createMsgNotes(json.info);	
				refreshMsgPageUI();
			}else{
				alert('查询商品列表失败！');
			}
		}	
	);
}
//创建商品列表数据
function createMsgNotes(objs){		
	var c="";
	for(var i=0;i<objs.length;i++){
		var obj=objs[i];	
		var cc=obj.msgContent;
		if(cc.length>100){
			cc=cc.substr(0,100)+"...";
		}
		c+='<li">';
		c+='<div class="context_box" onclick="location.href=\'${ctx}/front!viewContextDetail.action?msgId='+obj.msgId+'\';">';
		c+='	<dl>';
		c+='    	<dt class="context_pic">';
		c+='        	<a>';
		c+='            	<img src="${ctx}/frontSys!getPic.action?name='+obj.msgPic+'" width="129" height="89"/>';
		c+='            </a>';
		c+='        </dt>';
		c+='        <dd class="context_title">';
		c+='        	<a class="float_rg"><strong>'+obj.countLook+'</strong>查看</a>';
		c+='        	<h2>'+obj.msgTitle+'</h2>';
		c+='        </dd>';
		c+='        <dd class="context_desc">'+cc+'</dd>';
		c+='        <dd class="context_time">';
		c+='        	发表于：'+formatDate(obj.createTime);
		c+='        </dd>';
		c+='    </dl>';
		c+='</div>';
		c+='</li>'; 
	}	
	$('#msgContent').html(c);
}
//移至上一页
function movePre(){	
	--curPage;	
	_doPage();    
}
//移至下一页
function moveNext(){
	++curPage;	
	_doPage();
}
//点击go
function clickGo(id){	
	curPage=parseInt($('#'+id).val());
	_doPage();
}
//页面刷新方法
function _doPage(){		
	if(curPage>allPage){
		curPage=allPage;		
	}else if(curPage<1){
		curPage=1;	
	}
	doMsgQuery();
}
//刷新界面元素
function refreshMsgPageUI(){	
	allPage=Math.floor(allCount/pageSize)+(allCount%pageSize==0?0:1);
	$("#preBt").attr("class", curPage>1?"page_pre":"page_pre_unable");
	$("#nextBt").attr("class", curPage<allPage?"page_next":"page_next_unable");	
	$("#page").val(curPage);	
	$("#allPage_show").html("页 共"+allPage+"页");
}
//格式化日期：yyyy-MM-dd HH:mm:ss
function formatDate(time){
	var date=new Date(time);
	var m = date.getMonth()+1;
	var d = date.getDate();
	var H=date.getHours();
	var n=date.getMinutes();
	var s=date.getSeconds();
	return date.getFullYear()+"-"+(m<10?('0'+m):m)+"-"+(d<10?('0'+d):d)+" "+(H<10?('0'+H):H)+":"+(n<10?('0'+n):n)+":"+(s<10?('0'+s):s);
}
//-->
</script>
<script type="text/javascript">
<!--
//查询猜你喜欢列表
function doGuessQuery(){	
	var url="${ctx}/front!getGuessList.action";
	$.post(url, "num=5" ,function callback(txt){   
			var json = $.parseJSON(txt);
			if (json.code==0) {
				createGuessNotes(json.info);				
			}else{
				alert('查询猜你喜欢列表失败！');
			}
		}	
	);
}
//创建猜你喜欢数据
function createGuessNotes(objs){		
	var c='';
	for(var i=0;i<objs.length;i++){
		var obj=objs[i];
		c+='<li>'; 
		c+='<a href="javascript:goDetail(\''+obj.goodsId+'\');" class="context_pic"><img src="${ctx}/frontSys!getPic.action?name='+obj.goodsPic+'" alt="'+obj.goodsName+'" width="152" height="160" /></a>';
		c+='<a href="javascript:goDetail(\''+obj.goodsId+'\');" class="context_title">'+obj.goodsName+'</a>';
		c+='</li>';
	}
	$('#guessContent').html(c);
}
//-->
</script>
